package cn.tedu.hhmc.service_items.controller;

import java.util.List;
import javax.servlet.http.HttpServletResponse;

import cn.tedu.hhmc.base.response.JsonResult;
import cn.tedu.hhmc.service_items.pojo.entity.ServiceItems;
import cn.tedu.hhmc.service_items.service.IServiceItemsService;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.web.bind.annotation.GetMapping;
import org.springframework.web.bind.annotation.PostMapping;
import org.springframework.web.bind.annotation.PutMapping;
import org.springframework.web.bind.annotation.DeleteMapping;
import org.springframework.web.bind.annotation.PathVariable;
import org.springframework.web.bind.annotation.RequestBody;
import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.bind.annotation.RestController;

/**
 * 服务项目Controller
 * 
 * @author ruoyi
 * @date 2024-12-05
 */
@RestController
@RequestMapping("/hhmc/items")
public class ServiceItemsController
{
    @Autowired
    private IServiceItemsService serviceItemsService;

    /**
     * 查询全部服务项目列表
     */
    @GetMapping("/list")
    public JsonResult list()
    {
        List<ServiceItems> list = serviceItemsService.selectServiceItemsList(new ServiceItems());
        return JsonResult.ok(list);
    }

    /**
     * 查询服务项目列表
     */
    @GetMapping("/select")
    public JsonResult select(ServiceItems serviceItems)
    {
        List<ServiceItems> list = serviceItemsService.selectServiceItemsList(serviceItems);
        return JsonResult.ok(list);
    }

    /**
     * 导出服务项目列表
     */
    @PostMapping("/export")
    public void export(HttpServletResponse response, ServiceItems serviceItems)
    {
        List<ServiceItems> list = serviceItemsService.selectServiceItemsList(serviceItems);
//        ExcelUtil<ServiceItems> util = new ExcelUtil<ServiceItems>(ServiceItems.class);
//        util.exportExcel(response, list, "服务项目数据");
    }

    /**
     * 获取服务项目详细信息
     */
    @GetMapping(value = "/{id}")
    public JsonResult getInfo(@PathVariable("id") Long id)
    {
        return JsonResult.ok(serviceItemsService.selectServiceItemsById(id));
    }

    /**
     * 新增服务项目
     */
    @PostMapping
    public JsonResult add(@RequestBody ServiceItems serviceItems)
    {
        serviceItemsService.insertServiceItems(serviceItems);
        return JsonResult.ok();
    }

    /**
     * 修改服务项目
     */
    @PutMapping
    public JsonResult edit(@RequestBody ServiceItems serviceItems)
    {
        serviceItemsService.updateServiceItems(serviceItems);
        return JsonResult.ok();
    }

    /**
     * 删除服务项目
     */
	@DeleteMapping("/{ids}")
    public JsonResult remove(@PathVariable Long[] ids)
    {
        serviceItemsService.deleteServiceItemsByIds(ids);
        return JsonResult.ok();
    }
}
